//
//  SZRecommendMainController.m
//  KaiJing
//
//  Created by lanou on 16/1/11.
//  Copyright © 2016年 HuangZuCui. All rights reserved.
//

#import "SZRecommendMainController.h"
#import <SDCycleScrollView.h>
#import "PKRequestManager.h"

#define kRecommendMainURL @"http://morguo.com/forum.php?mod=movieexplorer&v=3&androidflag=1&appfrom=ios&iosversion=3.13&page=1&pdateline=0"

@interface SZRecommendMainController ()
/** 无限轮播图 */
@property (nonatomic, strong) SDCycleScrollView *scrollView;
/** 轮播图数组 */
@property (nonatomic, strong) NSMutableArray *imageArray;
@end

@implementation SZRecommendMainController

- (void)viewDidLoad {
    [super viewDidLoad];
    _imageArray = [NSMutableArray array];
    [self setupData];
}

/**
 *  添加轮播图大表头
 */
- (void)addHeaderScrollViewWithArray:(NSArray *)imageArray {
    _scrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenWidth / 2) imageURLStringsGroup:imageArray];
    _scrollView.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;
    self.tableView.tableHeaderView = _scrollView;
}

/**
 *  解析数据
 */
- (void)setupData {
    [PKRequestManager requestWithUrlString:kRecommendMainURL parDic:nil method:GET finish:^(NSDictionary *dataDic) {
        NSArray *imageTempArray = dataDic[@"data"][@"explorerbannerlist"];
        for (NSDictionary *subDic in imageTempArray) {
            NSString *tempString = [NSString stringWithFormat:@"http://morguo.com/%@",subDic[@"image"]];
            [_imageArray addObject:tempString];
        }
        [self addHeaderScrollViewWithArray:_imageArray];
        
        
    } error:^(NSError *error) {
        SZLog(@"%@",error);
    }];
}

/*
 影评: acinecism: CJFilmCriticModel
 短片: threadvideo : HYMoreShortModel
 
 */

#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 0;
}



@end
